using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Plugin;
using MicroMsg.Plugin.DriftBottle.Scene;
using MicroMsg.Protocol;
using MicroMsg.Resource.@string;
using MicroMsg.Storage;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Shell;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
namespace MicroMsg.UI.Page
{
	public class DriftBottleMainPage : ChatContainerPage
	{
		private enum PickingStatus
		{
			NotPicking,
			Picking,
			Picked,
			Opened
		}
		private enum DayOrNight
		{
			Day = 1,
			Night
		}
		public delegate void UnDoDlg();
		private const string TAG = "DriftBottleMainPage";
		private const uint cNPickBtlWaterCnt = 3u;
		private const uint cNPickBtleFloatAniCnt = 2u;
		private const uint cNThrowBottleDuaration = 1500u;
		private const uint cNThrowBottleWaterCnt = 1u;
		private const uint CNThrowBottleAllDuaration = 3200u;
		private const uint cNWaterAnimationTime = 800u;
		private const int cNWaterPosMinX = 50;
		private const int cNWaterPosMaxX = 200;
		private const int CNWaterPosMinY = 0;
		private const int CNWaterPosMaxY = 80;
		private const int cNBaloonMaxX = 408;
		private const int cNBaloonMinX = 0;
		private const int cNBaloonMaxY = 200;
		private const int cNBaloonMinY = 0;
		private const int cNBaloonMaxDistanceX = 20;
		private const int cNBaloonMaxDistanceY = 20;
		private const string cStrFloatStarFish = "/Source/Plugin/DriftBottle/Resource/Img/starFish.png";
		private const string cStrFloatVoiceBottle = "/Source/Plugin/DriftBottle/Resource/Img/bottleRecord.png";
		private const string cStrFloatLetterBottle = "/Source/Plugin/DriftBottle/Resource/Img/bottleWriting.png";
		private const uint cNFloatAniDuaration = 1500u;
		private const int cNOpenHintDuaration = 2000;
		private const int cNOpenHintXMove = -10;
		private const int cNOpenHintYMove = -10;
		private const string cStrMsgBottleEmpty = "/Source/Plugin/DriftBottle/Resource/Img/bottleEmpty.png";
		private const string cStrMsgBottleLetter = "/Source/Plugin/DriftBottle/Resource/Img/bottleLetter.png";
		private const string cStrMsgBottleVoice = "/Source/Plugin/DriftBottle/Resource/Img/bottleVoice.png";
		private EventWatcher mWatchDriftBottleEvent;
		private EventWatcher mWatchBConStoreChange;
		private object objWatch = new object();
		private MsgBottleKind mLastPickedBtleKind;
		private UITaskManager mTaskMgrShowBtle;
		private ChatMsg mBtleMsg;
		private UITaskManager mTaskMgrOpenBtle;
		private bool mBIsBtleOpend;
		private bool mBIsEnableFloatObjectClick;
		private double mDimgMsgBottlePosX;
		private double mDimgMsgBottlePosY;
		private double mDimgMsgBottleH;
		private double mDimgMsgBottleW;
		private bool mBIsMakingWater;
		private Storyboard mSbMakeWater;
		private UITaskDlg mMakeWaterCmpletHanlder;
		private int mNMakeWaterCnt;
		private List<Point> mWaterPoints;
		private bool mBIsUsingDftPtMakeWater;
		private int mNMakeWaterTimes;
		private bool mBIsStartBaloonAnimation;
		private bool mBIsTowerLightAnimating;
		private Storyboard mSbTowerLight;
		private Storyboard mSBFloatObject;
		private DateTime mTimeFloatStart;
		private FrameworkElement mElementOpenBotleHint;
		private Storyboard mSbOpenHintAni;
		private uint cNShowMsgObjectDuaration;
		private bool mBIsBlackCoverOn;
		private bool mBIsLightOn;
		private bool mBIsPicking;
		private DriftBottleMainPage.PickingStatus mPickingStatus;
		private DriftBottleMainPage.DayOrNight mDayOrNight;
		private string mStrMoonSourcePre;
		private bool mBIsUIInited;
		private UIElement mElementAbove;
		private bool mBIsLockBgClick;
		private ApplicationBar mBar;
		private bool mBIsDay;
		private bool mBIsBackKeyEnabled;
		private static bool sBIsUndoLocked;
		private List<DriftBottleMainPage.UnDoDlg> listUndos;
		private int mNdoUnDoLevel;
		private List<DriftBottleMainPage.UnDoDlg> mUndoIgnore;
		internal Grid realLayoutRoot;
		internal Grid LayoutRoot;
		internal ImageBrush imgBrushBG;
		internal Image imgBalloon;
		internal Image imgMoon;
		internal Image imgTowerLight;
		internal Canvas canvasRoot;
		internal Button btnRoot;
		internal Grid canvasToolBar;
		internal Button btnThrowBottle;
		internal Button btnPickBottle;
		internal Button btnSeeMyBottles;
		internal Grid gridBtleCnt;
		internal TextBlock txtBtleCnt;
		internal Canvas canvasMsgBottle;
		internal Image imgMsgBottle;
		internal Image imgMsgObject;
		internal Button btnFloatObject;
		internal Image imgFloatObject;
		internal Canvas canvasWaterFlower;
		internal Image imgWaterFlower1;
		internal Image imgWaterFlower2;
		internal Image imgWaterFlower3;
		internal StackPanel panelOpenHint;
		internal Image imgOpenHint;
		internal TextBlock txtOpenHint;
		private bool _contentLoaded;
		private Canvas mElementToThrow
		{
			get
			{
				return this.canvasMsgBottle;
			}
			set
			{
				this.mElementToThrow = value;
			}
		}
		public DriftBottleMainPage()
		{
			List<Point> list = new List<Point>();
			list.Add(new Point(50.0, 0.0));
			this.mWaterPoints = list;
			this.mNMakeWaterTimes = -1;
			this.mTimeFloatStart = DateTime.MinValue;
			this.cNShowMsgObjectDuaration = 500u;
			this.mDayOrNight = DriftBottleMainPage.DayOrNight.Day;
			this.mStrMoonSourcePre = "/Source/Plugin/DriftBottle/Resource/Img/sandyMoon00";
			this.mBIsBackKeyEnabled = true;
			this.listUndos = new List<DriftBottleMainPage.UnDoDlg>();
			this.mUndoIgnore = new List<DriftBottleMainPage.UnDoDlg>();
			base..ctor();
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.Page_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.Page_Unloaded));
			this.setAppBar();
		}
		private void Page_Loaded(object sender, RoutedEventArgs e)
		{
			Log.smethod_5("DriftBottleMainPage", "Page_Loaded");
			this.refreshUnReadBottle();
		}
		private void Page_Unloaded(object sender, RoutedEventArgs e)
		{
			Log.smethod_5("DriftBottleMainPage", "Page_Loaded");
		}
		protected override void OnPageIn(object[] object_0)
		{
			Log.smethod_5("DriftBottleMainPage", "OnPageIn");
			this.initUI();
			this.initScene();
			this.registerEvent();
		}
		protected override void OnPageOut()
		{
			base.PreOnPageOut();
			Log.smethod_5("DriftBottleMainPage", "OnPageOut");
			this.unRegisterEvent();
		}
		protected override void OnPageForward(Uri targetPage)
		{
			base.PreOnPageForward(targetPage);
		}
		protected override void OnPageBack()
		{
			base.PreOnPageBack();
		}
		protected override bool IsAlertMsgNeedShow(ChatMsg chatMsg_0)
		{
			bool flag = true;
			return !base.PreIsAlertMsgNeedShow(chatMsg_0, ref flag) || flag;
		}
		public override List<UIElement> GetBkContents()
		{
			List<UIElement> list = new List<UIElement>();
			list.Add(this.LayoutRoot);
			return list;
		}
		public override Panel GetChatContainerPanel()
		{
			return this.realLayoutRoot;
		}
		protected override void resumeFromChat()
		{
		}
		private void registerEvent()
		{
			if (this.mWatchDriftBottleEvent == null)
			{
				this.mWatchDriftBottleEvent = new EventWatcher(this.objWatch, null, new EventHandlerDelegate(this.OnDriftBottleEvent));
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_GRIFTBOTTLE_EVENT, this.mWatchDriftBottleEvent);
			}
			if (this.mWatchBConStoreChange == null)
			{
				this.mWatchBConStoreChange = new EventWatcher(this.objWatch, null, new EventHandlerDelegate(this.OnBConStoreChange));
				EventCenter.registerEventWatcher(EventConst.ON_BCONVERSATION_LIST_CHANGE, this.mWatchBConStoreChange);
			}
		}
		private void unRegisterEvent()
		{
			if (this.mWatchDriftBottleEvent != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_GRIFTBOTTLE_EVENT, this.mWatchDriftBottleEvent);
				this.mWatchDriftBottleEvent = null;
			}
			if (this.mWatchBConStoreChange != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_BCONVERSATION_LIST_CHANGE, this.mWatchBConStoreChange);
				this.mWatchBConStoreChange = null;
			}
		}
		private void OnBConStoreChange(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.refreshUnReadBottle();
		}
		private void OnDriftBottleEvent(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (evtArgs != null && evtArgs.mObject != null && evtArgs.mObject is BottleRetbase)
			{
				BottleRetbase bottleRetbase = evtArgs.mObject as BottleRetbase;
				BottleEvent bottleEvent_ = bottleRetbase.bottleEvent_0;
				Log.smethod_5("DriftBottleMainPage", "OnDriftBottleEvent:" + bottleEvent_);
				switch (bottleEvent_)
				{
				case BottleEvent.ON_NETSCENE_GETBOTTLECOUNT_SUCCESS:
				case BottleEvent.ON_NETSCENE_GETBOTTLECOUNT_FAIL:
					if (bottleRetbase is BottleCountRet)
					{
						this.procGetBtleCntRet(bottleRetbase as BottleCountRet);
						return;
					}
					break;
				case BottleEvent.ON_NETSCENE_OPENBOTTLE_SUCCESS:
				case BottleEvent.ON_NETSCENE_OPENBOTTLE_FAIL:
					if (!this.mBIsPicking)
					{
						return;
					}
					if (this.mPickingStatus != DriftBottleMainPage.PickingStatus.Picked)
					{
						return;
					}
					if (bottleRetbase is OpenBottleRet)
					{
						this.procOpenBtleRet(bottleRetbase as OpenBottleRet);
						return;
					}
					break;
				case BottleEvent.ON_NETSCENE_PICKBOTTLE_SUCCESS:
				case BottleEvent.ON_NETSCENE_PICKBOTTLE_FAIL:
					if (!this.mBIsPicking)
					{
						return;
					}
					if (DriftBottleMainPage.PickingStatus.Picking != this.mPickingStatus)
					{
						return;
					}
					if (bottleRetbase is PickBottleRet)
					{
						this.procPickBtleRet(bottleRetbase as PickBottleRet);
					}
					break;
				default:
					return;
				}
				return;
			}
		}
		private void procPickBtleRet(PickBottleRet pickBtleRet)
		{
			if (pickBtleRet == null)
			{
				return;
			}
			switch (pickBtleRet.bottleEvent_0)
			{
			case BottleEvent.ON_NETSCENE_PICKBOTTLE_SUCCESS:
				this.mPickingStatus = DriftBottleMainPage.PickingStatus.Picked;
				this.showPickedBottle((MsgBottleKind)pickBtleRet.bottleType);
				return;
			case BottleEvent.ON_NETSCENE_PICKBOTTLE_FAIL:
				if (RetConst.MM_ERR_NO_BOTTLECOUNT != pickBtleRet.serverRetCode && RetConst.MM_BOTTLE_COUNT_ERR != pickBtleRet.serverRetCode)
				{
					if (RetConst.MM_BOTTLE_PICKCOUNTINVALID != pickBtleRet.serverRetCode)
					{
						this.showPickedBottle(MsgBottleKind.Bt_Null);
						return;
					}
				}
				Log.smethod_5("DriftBottleMainPage", "procPickBtleRet:MM_BOTTLE_COUNT_ERR");
				MMMessageBox.Show(strings.Float_Bottle_No_Fish_Bottle, true, "确定");
				DriftBottleMainPage.unlockUndo();
				this.doUndo();
				return;
			default:
				return;
			}
		}
		private void showPickedBottle(MsgBottleKind msgBtleKind)
		{
			Log.smethod_5("DriftBottleMainPage", "showPickedBottle:" + msgBtleKind);
			this.mLastPickedBtleKind = msgBtleKind;
			List<UITask> list = new List<UITask>();
			list.Add(new UITask(new UITaskDlg(DriftBottleMainPage.lockUndo), 0u));
			list.Add(new UITask(new UITaskDlg(this.stopMakeWaterAnimation), 0u));
			List<UITask> list2 = list;
			if (msgBtleKind != MsgBottleKind.Bt_Null && msgBtleKind != MsgBottleKind.Bt_CntInvalid)
			{
				if (msgBtleKind != MsgBottleKind.Bt_Img)
				{
					return;
				}
			}
			list2.Add(new UITask(new UITaskDlg(DriftBottleMainPage.unlockUndo), 0u));
			list2.Add(new UITask(new UITaskDlg(this.unLockBgClick), 0u));
			list2.Add(new UITask(new UITaskDlgEx(this.startFloatObjectAnimation), msgBtleKind, 0u));
			list2.Add(new UITask(new UITaskDlg(DriftBottleMainPage.unlockUndo), 3000u));
			list2.Add(new UITask(new UITaskDlg(this.doUndo), 0u));
			UITaskManager uITaskManager = new UITaskManager(list2, null);
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.turnOffLight));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.stopFloatObjectAnimation));
			uITaskManager.StartTasks(0u);
			this.mTaskMgrShowBtle = uITaskManager;
		}
		private void stopShowPickTask()
		{
			if (this.mTaskMgrShowBtle != null)
			{
				this.mTaskMgrShowBtle.StopTasks();
				this.mTaskMgrShowBtle = null;
			}
		}
		private void setBtleMsg(object object_0)
		{
			if (object_0 != null && object_0 is ChatMsg)
			{
				this.mBtleMsg = (object_0 as ChatMsg);
			}
		}
		private void clearBtleMsg()
		{
			this.mBtleMsg = null;
		}
		private void procOpenBtleRet(OpenBottleRet openBtleRet)
		{
			if (openBtleRet == null)
			{
				return;
			}
			switch (openBtleRet.bottleEvent_0)
			{
			case BottleEvent.ON_NETSCENE_OPENBOTTLE_SUCCESS:
			{
				this.mPickingStatus = DriftBottleMainPage.PickingStatus.Opened;
				List<UITask> list = new List<UITask>();
				list.Add(new UITask(new UITaskDlg(DriftBottleMainPage.unlockUndo), 0u));
				list.Add(new UITask(new UITaskDlg(this.lockBgClick), 0u));
				list.Add(new UITask(new UITaskDlg(this.enableFloatObjectClick), 0u));
				list.Add(new UITask(new UITaskDlg(this.stopMakeWaterAnimation), 0u));
				list.Add(new UITask(new UITaskDlgEx(this.setBtleMsg), openBtleRet.chatInfo, 0u));
				list.Add(new UITask(new UITaskDlgEx(this.startFloatObjectAnimation), this.mLastPickedBtleKind, 3000u));
				list.Add(new UITask(new UITaskDlg(this.stopFloatObjectAnimation), 0u));
				list.Add(new UITask(new UITaskDlg(this.startOpenBtlHint), 0u));
				list.Add(new UITask(new UITaskDlg(this.showFloatObject), 0u));
				List<UITask> listTasks = list;
				this.mTaskMgrOpenBtle = new UITaskManager(listTasks, null);
				this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.stopOpenBtlTask));
				this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.disableFloatObjectClick));
				this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.turnOffLight));
				this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.unLockBgClick));
				this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.hideFloatObject));
				this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.stopOpenBtlHint));
				this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.stopFloatObjectAnimation));
				this.mTaskMgrOpenBtle.StartTasks(0u);
				Log.smethod_5("DriftBottleMainPage", "procOpenBtleRet  nStartTime = " + 0u);
				return;
			}
			case BottleEvent.ON_NETSCENE_OPENBOTTLE_FAIL:
			{
				List<UITask> list2 = new List<UITask>();
				list2.Add(new UITask(new UITaskDlg(this.stopMakeWaterAnimation), 0u));
				List<UITask> list3 = list2;
				list3.Add(new UITask(new UITaskDlg(DriftBottleMainPage.unlockUndo), 0u));
				list3.Add(new UITask(new UITaskDlg(this.unLockBgClick), 0u));
				list3.Add(new UITask(new UITaskDlgEx(this.startFloatObjectAnimation), MsgBottleKind.Bt_Null, 0u));
				list3.Add(new UITask(new UITaskDlg(DriftBottleMainPage.unlockUndo), 3000u));
				list3.Add(new UITask(new UITaskDlg(this.doUndo), 0u));
				UITaskManager uITaskManager = new UITaskManager(list3, null);
				this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.turnOffLight));
				this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.stopFloatObjectAnimation));
				uITaskManager.StartTasks(0u);
				return;
			}
			default:
				return;
			}
		}
		private void setBtleIsOpend()
		{
			this.mBIsBtleOpend = true;
		}
		private void setBtleUnOpend()
		{
			this.mBIsBtleOpend = false;
		}
		private bool isBtleOpend()
		{
			return this.mBIsBtleOpend;
		}
		private void stopOpenBtlTask()
		{
			if (this.mTaskMgrOpenBtle != null)
			{
				this.mTaskMgrOpenBtle.StopTasks();
				this.mTaskMgrOpenBtle = null;
			}
		}
		private void procGetBtleCntRet(BottleCountRet getBtleCntRet)
		{
		}
		private void initScene()
		{
			if (DriftBottleServiceCenter.scenePickBottle == null)
			{
				DriftBottleServiceCenter.init();
			}
		}
		private void doPickBottle()
		{
			if (DriftBottleServiceCenter.scenePickBottle == null)
			{
				return;
			}
			DriftBottleServiceCenter.scenePickBottle.doScene();
		}
		private void btnThrowBottle_Click(object sender, RoutedEventArgs e)
		{
			this.toWriteMsgMode();
		}
		private void btnPickBottle_Click(object sender, RoutedEventArgs e)
		{
			this.changeToPickBottle();
		}
		private void btnSeeMyBottles_Click(object sender, RoutedEventArgs e)
		{
			base.GoToPage("/Source/Plugin/DriftBottle/UI/BottlesListPage.xaml", new object[]
			{
				BottlesListPage.BottleListPageEntryType.fromDriftBottleMain
			}, false);
			for (int i = 0; i < PageManager.getInstance().basePageList.get_Count(); i++)
			{
				if (PageManager.getInstance().basePageList.get_Item(i) is BottlesListPage)
				{
					PageManager.getInstance().PopPage();
					return;
				}
			}
		}
		private void btnRoot_Click(object sender, RoutedEventArgs e)
		{
			if (this.canClickBg())
			{
				this.unDoOneThing();
			}
		}
		private void btnFloatObject_Click(object sender, RoutedEventArgs e)
		{
			if (this.mBIsEnableFloatObjectClick)
			{
				this.disableFloatObjectClick();
				this.hideFloatObject();
				DriftBottleMainPage.unlockUndo();
				this.toOpenBtleMode();
				return;
			}
			this.btnRoot_Click(null, null);
		}
		private void enableFloatObjectClick()
		{
			this.mBIsEnableFloatObjectClick = true;
		}
		private void disableFloatObjectClick()
		{
			this.mBIsEnableFloatObjectClick = false;
		}
		private void throwBottleAnimation()
		{
			this.turnOnLight();
			Storyboard storyboard = new Storyboard();
			this.mElementToThrow.set_Visibility(0);
			RotateTransform rotateTransform = new RotateTransform();
			this.mElementToThrow.set_RenderTransform(rotateTransform);
			this.mElementToThrow.set_RenderTransformOrigin(new Point(0.5, 0.5));
			DoubleAnimation doubleAnimation = this.createAnimation(0.0, 792.00000000000011, rotateTransform, "Angle", 1500u);
			DoubleAnimation arg_8E_0 = doubleAnimation;
			PowerEase powerEase = new PowerEase();
			powerEase.set_EasingMode(1);
			powerEase.set_Power(0.8);
			arg_8E_0.set_EasingFunction(powerEase);
			storyboard.get_Children().Add(doubleAnimation);
			doubleAnimation = this.createAnimation(1.0, 0.3, this.mElementToThrow, "Opacity", 1500u);
			DoubleAnimation arg_EA_0 = doubleAnimation;
			PowerEase powerEase2 = new PowerEase();
			powerEase2.set_EasingMode(1);
			powerEase2.set_Power(1.3);
			arg_EA_0.set_EasingFunction(powerEase2);
			storyboard.get_Children().Add(doubleAnimation);
			this.mDimgMsgBottlePosX = (double)this.mElementToThrow.GetValue(Canvas.LeftProperty);
			this.mDimgMsgBottlePosY = (double)this.mElementToThrow.GetValue(Canvas.TopProperty);
			doubleAnimation = this.createAnimation(this.mDimgMsgBottlePosX, this.mDimgMsgBottlePosX - 150.0, this.mElementToThrow, "(Canvas.Left)", 1500u);
			DoubleAnimation arg_180_0 = doubleAnimation;
			PowerEase powerEase3 = new PowerEase();
			powerEase3.set_EasingMode(1);
			powerEase3.set_Power(1.3);
			arg_180_0.set_EasingFunction(powerEase3);
			storyboard.get_Children().Add(doubleAnimation);
			doubleAnimation = this.createAnimation(this.mDimgMsgBottlePosY, this.mDimgMsgBottlePosY - 110.0, this.mElementToThrow, "(Canvas.Top)", 1500u);
			DoubleAnimation arg_1E0_0 = doubleAnimation;
			PowerEase powerEase4 = new PowerEase();
			powerEase4.set_EasingMode(1);
			powerEase4.set_Power(1.2);
			arg_1E0_0.set_EasingFunction(powerEase4);
			storyboard.get_Children().Add(doubleAnimation);
			this.mDimgMsgBottleH = this.mElementToThrow.get_ActualHeight();
			doubleAnimation = this.createAnimation(this.mDimgMsgBottleH, this.mDimgMsgBottleH * 0.3, this.mElementToThrow, "Height", 1500u);
			storyboard.get_Children().Add(doubleAnimation);
			this.mDimgMsgBottleW = this.mElementToThrow.get_ActualWidth();
			doubleAnimation = this.createAnimation(this.mDimgMsgBottleW, this.mDimgMsgBottleW * 0.3, this.mElementToThrow, "Width", 1500u);
			storyboard.get_Children().Add(doubleAnimation);
			storyboard.add_Completed(new EventHandler(this.sbThrowBottle_Completed));
			storyboard.Begin();
		}
		private void sbThrowBottle_Completed(object sender, EventArgs e)
		{
			if (this.mElementToThrow == null)
			{
				return;
			}
			this.mElementToThrow.set_RenderTransform(null);
			this.mElementToThrow.set_Visibility(1);
			this.mElementToThrow.set_Opacity(1.0);
			this.mElementToThrow.SetValue(Canvas.LeftProperty, this.mDimgMsgBottlePosX);
			this.mElementToThrow.SetValue(Canvas.TopProperty, this.mDimgMsgBottlePosY);
			this.mElementToThrow.set_Height(this.mDimgMsgBottleH);
			this.mElementToThrow.set_Width(this.mDimgMsgBottleW);
			this.useDftPtMakeWater();
			this.startMakeWaterAnimation();
			this.mNMakeWaterTimes = 0;
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.stopMakeWaterAnimation));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.notUseDftPtMakeWater));
		}
		private void insertMsgToBottleAnimation()
		{
		}
		private void startMakeWaterAnimation()
		{
			this.getWaterNextPoint();
			this.canvasWaterFlower.set_Visibility(0);
			this.mSbMakeWater = new Storyboard();
			DoubleAnimation doubleAnimation = this.createAnimation(0.0, 1.0, this.imgWaterFlower1, "Opacity", 400u);
			doubleAnimation.set_BeginTime(new TimeSpan?(TimeSpan.FromMilliseconds(0)));
			doubleAnimation.set_AutoReverse(true);
			this.mSbMakeWater.get_Children().Add(doubleAnimation);
			doubleAnimation = this.createAnimation(0.0, 1.0, this.imgWaterFlower2, "Opacity", 400u);
			doubleAnimation.set_BeginTime(new TimeSpan?(TimeSpan.FromMilliseconds(200)));
			doubleAnimation.set_AutoReverse(true);
			this.mSbMakeWater.get_Children().Add(doubleAnimation);
			doubleAnimation = this.createAnimation(0.0, 1.0, this.imgWaterFlower3, "Opacity", 400u);
			doubleAnimation.set_BeginTime(new TimeSpan?(TimeSpan.FromMilliseconds(400)));
			doubleAnimation.set_AutoReverse(true);
			this.mSbMakeWater.get_Children().Add(doubleAnimation);
			this.mSbMakeWater.add_Completed(new EventHandler(this.sbMakeWater_Completed));
			this.mSbMakeWater.Begin();
			this.mBIsMakingWater = true;
			this.mNMakeWaterCnt++;
			this.mNMakeWaterTimes--;
		}
		private void useDftPtMakeWater()
		{
			this.mBIsUsingDftPtMakeWater = true;
		}
		private void notUseDftPtMakeWater()
		{
			this.mBIsUsingDftPtMakeWater = false;
		}
		private void getWaterNextPoint()
		{
			double num;
			double num2;
			if (this.mBIsUsingDftPtMakeWater && this.mWaterPoints != null && this.mNMakeWaterCnt < this.mWaterPoints.get_Count())
			{
				num = this.mWaterPoints.get_Item(this.mNMakeWaterCnt).get_X();
				num2 = this.mWaterPoints.get_Item(this.mNMakeWaterCnt).get_Y();
			}
			else
			{
				Random random = new Random();
				num = (double)random.Next(50, 200);
				num2 = (double)random.Next(0, 80);
			}
			this.canvasWaterFlower.SetValue(Canvas.LeftProperty, num);
			this.canvasWaterFlower.SetValue(Canvas.TopProperty, num2);
		}
		private void sbMakeWater_Completed(object sender, EventArgs e)
		{
			if (this.mNMakeWaterTimes == 0)
			{
				this.makeWaterAnimationStoped();
				return;
			}
			if (this.mBIsMakingWater)
			{
				this.startMakeWaterAnimation();
				return;
			}
			this.makeWaterAnimationStoped();
		}
		private void stopMakeWaterAnimation()
		{
			this.canvasWaterFlower.set_Visibility(1);
			this.mBIsMakingWater = false;
			this.mNMakeWaterTimes = -1;
		}
		private void stopMakeWaterAnimation(object completHandler)
		{
			if (completHandler is UITaskDlg)
			{
				this.mMakeWaterCmpletHanlder = (completHandler as UITaskDlg);
			}
			this.canvasWaterFlower.set_Visibility(1);
			this.mBIsMakingWater = false;
			this.mNMakeWaterTimes = -1;
		}
		private void makeWaterAnimationStoped()
		{
			this.mBIsMakingWater = false;
			this.mNMakeWaterTimes = -1;
			this.mNMakeWaterCnt = 0;
			this.mSbMakeWater = null;
			this.canvasWaterFlower.set_Visibility(1);
			if (this.mMakeWaterCmpletHanlder != null)
			{
				this.mMakeWaterCmpletHanlder();
				this.mMakeWaterCmpletHanlder = null;
			}
		}
		private void startBaloonAnimation()
		{
			this.imgBalloon.set_Visibility(0);
			this.mBIsStartBaloonAnimation = true;
			Storyboard storyboard = new Storyboard();
			double num = (double)this.imgBalloon.GetValue(Canvas.LeftProperty);
			double num2 = (double)this.imgBalloon.GetValue(Canvas.TopProperty);
			Point baloonNextPoint = this.getBaloonNextPoint(num, num2);
			DoubleAnimation doubleAnimation = this.createAnimation(num, baloonNextPoint.get_X(), this.imgBalloon, "(Canvas.Left)", 4000u);
			storyboard.get_Children().Add(doubleAnimation);
			doubleAnimation = this.createAnimation(num2, baloonNextPoint.get_Y(), this.imgBalloon, "(Canvas.Top)", 4000u);
			storyboard.get_Children().Add(doubleAnimation);
			storyboard.add_Completed(new EventHandler(this.sbBaloon_Completed));
			storyboard.Begin();
		}
		private void stopBaloonAnimation()
		{
			this.mBIsStartBaloonAnimation = false;
			this.imgBalloon.set_Visibility(1);
		}
		private void sbBaloon_Completed(object sender, EventArgs e)
		{
			if (sender != null && sender is Storyboard && this.mBIsStartBaloonAnimation)
			{
				this.startBaloonAnimation();
			}
		}
		private Point getBaloonNextPoint(double originX, double originY)
		{
			Random random = new Random();
			int num = random.Next(20);
			if (num % 2 == 0)
			{
				num = -num;
			}
			int num2 = random.Next(20);
			if (num2 % 2 == 0)
			{
				num2 = -num2;
			}
			Point result = default(Point);
			result.set_X(originX + (double)num);
			result.set_Y(originY + (double)num2);
			if (result.get_X() > 408.0)
			{
				result.set_X(408.0);
			}
			if (result.get_X() < 0.0)
			{
				result.set_X(0.0);
			}
			if (result.get_Y() > 200.0)
			{
				result.set_Y(200.0);
			}
			if (result.get_Y() < 0.0)
			{
				result.set_Y(0.0);
			}
			return result;
		}
		private void startTowerLightAnimation()
		{
			this.imgTowerLight.set_Visibility(0);
			this.mSbTowerLight = new Storyboard();
			QuadraticEase quadraticEase = new QuadraticEase();
			quadraticEase.set_EasingMode(2);
			DoubleAnimation doubleAnimation = this.createAnimation(0.0, 360.0, this.imgTowerLight.get_Projection(), "RotationY", 24000u);
			this.mSbTowerLight.get_Children().Add(doubleAnimation);
			doubleAnimation = this.createAnimation(1.0, 0.0, this.imgTowerLight, "Opacity", 24000u / 4u);
			doubleAnimation.set_BeginTime(new TimeSpan?(TimeSpan.FromMilliseconds(24000 / 2)));
			doubleAnimation.set_AutoReverse(true);
			this.mSbTowerLight.get_Children().Add(doubleAnimation);
			this.mSbTowerLight.set_RepeatBehavior(RepeatBehavior.get_Forever());
			this.mSbTowerLight.add_Completed(new EventHandler(this.mSbTowerLight_Completed));
			this.mSbTowerLight.Begin();
		}
		private void mSbTowerLight_Completed(object sender, EventArgs e)
		{
		}
		private void stopTowerLightAnimation()
		{
			this.imgTowerLight.set_Visibility(1);
			if (this.mSbTowerLight != null)
			{
				this.mSbTowerLight.Stop();
			}
		}
		private void startFloatObjectAnimation(object object_0)
		{
			this.mTimeFloatStart = DateTime.get_Now();
			if (object_0 == null || !(object_0 is MsgBottleKind))
			{
				return;
			}
			MsgBottleKind msgBottleKind = (MsgBottleKind)object_0;
			string text;
			if (MsgBottleKind.Bt_Voice == msgBottleKind)
			{
				text = "/Source/Plugin/DriftBottle/Resource/Img/bottleRecord.png";
			}
			else
			{
				if (MsgBottleKind.Bt_Letter == msgBottleKind)
				{
					text = "/Source/Plugin/DriftBottle/Resource/Img/bottleWriting.png";
				}
				else
				{
					text = "/Source/Plugin/DriftBottle/Resource/Img/starFish.png";
				}
			}
			this.imgFloatObject.set_Visibility(0);
			this.imgFloatObject.set_Source(new BitmapImage(new Uri(text, 2)));
			UIElement uIElement = this.imgFloatObject;
			if (uIElement == null)
			{
				return;
			}
			Storyboard storyboard = new Storyboard();
			RotateTransform rotateTransform = new RotateTransform();
			uIElement.set_RenderTransform(rotateTransform);
			uIElement.set_RenderTransformOrigin(new Point(0.5, 0.5));
			DoubleAnimation doubleAnimation = this.createAnimation(0.0, 15.0, rotateTransform, "Angle", 1500u);
			doubleAnimation.set_AutoReverse(true);
			doubleAnimation.set_RepeatBehavior(RepeatBehavior.get_Forever());
			storyboard.get_Children().Add(doubleAnimation);
			doubleAnimation = this.createAnimation(1.0, 0.6, uIElement, "Opacity", 1500u);
			doubleAnimation.set_AutoReverse(true);
			doubleAnimation.set_RepeatBehavior(RepeatBehavior.get_Forever());
			storyboard.get_Children().Add(doubleAnimation);
			this.mSBFloatObject = storyboard;
			storyboard.set_RepeatBehavior(RepeatBehavior.get_Forever());
			storyboard.add_Completed(new EventHandler(this.sbFloatObject_Completed));
			storyboard.Begin();
		}
		private void sbFloatObject_Completed(object sender, EventArgs e)
		{
			this.imgFloatObject.set_RenderTransform(null);
			this.imgFloatObject.set_Visibility(1);
			this.mSBFloatObject = null;
			this.mTimeFloatStart = DateTime.MinValue;
		}
		private void stopFloatObjectAnimation()
		{
			if (this.mSBFloatObject != null)
			{
				this.imgFloatObject.set_Visibility(1);
				this.mSBFloatObject.Stop();
				this.mSBFloatObject = null;
			}
		}
		private void startOpenBtlHint()
		{
			this.mElementOpenBotleHint = this.panelOpenHint;
			Storyboard storyboard = new Storyboard();
			this.mElementOpenBotleHint.set_Visibility(0);
			CompositeTransform compositeTransform = new CompositeTransform();
			this.mElementOpenBotleHint.set_RenderTransform(compositeTransform);
			this.mElementOpenBotleHint.set_RenderTransformOrigin(new Point(0.5, 0.5));
			DoubleAnimation doubleAnimation = this.createAnimation(0.0, -10.0, compositeTransform, "TranslateX", 250u);
			doubleAnimation.set_BeginTime(new TimeSpan?(TimeSpan.FromMilliseconds(250 * 7)));
			doubleAnimation.set_AutoReverse(true);
			storyboard.get_Children().Add(doubleAnimation);
			doubleAnimation = this.createAnimation(0.0, -10.0, compositeTransform, "TranslateY", 250u);
			doubleAnimation.set_BeginTime(new TimeSpan?(TimeSpan.FromMilliseconds(250 * 7)));
			doubleAnimation.set_AutoReverse(true);
			storyboard.get_Children().Add(doubleAnimation);
			storyboard.set_RepeatBehavior(RepeatBehavior.get_Forever());
			storyboard.Begin();
			this.mSbOpenHintAni = storyboard;
		}
		private void stopOpenBtlHint()
		{
			if (this.mSbOpenHintAni != null)
			{
				this.mSbOpenHintAni.Stop();
			}
			if (this.mElementOpenBotleHint != null)
			{
				this.mElementOpenBotleHint.set_Visibility(1);
				this.mElementOpenBotleHint.set_RenderTransform(null);
			}
		}
		private DoubleAnimation createAnimation(double from, double double_0, DependencyObject target, string property, uint duration)
		{
			new Storyboard();
			DoubleAnimation doubleAnimation = new DoubleAnimation();
			doubleAnimation.set_From(new double?(from));
			doubleAnimation.set_To(new double?(double_0));
			doubleAnimation.set_Duration(TimeSpan.FromMilliseconds(duration));
			Storyboard.SetTarget(doubleAnimation, target);
			Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath(property, new object[0]));
			return doubleAnimation;
		}
		private void startShowMsgObjectAni()
		{
			Storyboard storyboard = new Storyboard();
			uint duration = this.cNShowMsgObjectDuaration;
			DoubleAnimation doubleAnimation = this.createAnimation(0.0, 1.0, this.imgMsgObject, "Opacity", duration);
			storyboard.get_Children().Add(doubleAnimation);
			storyboard.Begin();
		}
		private void showBtleCntHint()
		{
			this.gridBtleCnt.set_Visibility(0);
		}
		private void hideBtleCntHint()
		{
			this.gridBtleCnt.set_Visibility(1);
		}
		private void showToolBar()
		{
			this.canvasToolBar.set_Visibility(0);
			if (this.mBar != null)
			{
				base.set_ApplicationBar(this.mBar);
				base.get_ApplicationBar().set_IsVisible(true);
			}
		}
		private void hideToolBar()
		{
			this.canvasToolBar.set_Visibility(1);
			if (base.get_ApplicationBar() != null)
			{
				base.get_ApplicationBar().set_IsVisible(false);
			}
		}
		private void turnOnBlackCover()
		{
			this.mBIsBlackCoverOn = true;
			this.hideToolBar();
			Panel arg_2D_0 = this.canvasRoot;
			SolidColorBrush solidColorBrush = new SolidColorBrush();
			solidColorBrush.set_Color(Color.FromArgb(204, 0, 0, 0));
			arg_2D_0.set_Background(solidColorBrush);
		}
		private void turnOffBlackCover()
		{
			this.mBIsBlackCoverOn = false;
			this.showToolBar();
			this.canvasRoot.set_Background(null);
		}
		private void turnOnLight()
		{
			this.mBIsLightOn = true;
			this.hideToolBar();
			Panel arg_30_0 = this.canvasRoot;
			ImageBrush imageBrush = new ImageBrush();
			imageBrush.set_ImageSource(new BitmapImage(new Uri("/Source/Plugin/DriftBottle/Resource/Img/ThrowBottleBg.png", 0)));
			arg_30_0.set_Background(imageBrush);
		}
		private void turnOffLight()
		{
			if (this.mBIsLightOn)
			{
				this.mBIsLightOn = false;
				this.showToolBar();
				this.canvasRoot.set_Background(null);
			}
		}
		private void changeToPickBottle()
		{
			if (!DriftBottleServiceCenter.isPickBottleCountLeft())
			{
				MMMessageBox.Show(strings.Float_Bottle_No_Fish_Bottle, true, "确定");
				return;
			}
			this.stopShowPickTask();
			this.mBIsPicking = true;
			this.mPickingStatus = DriftBottleMainPage.PickingStatus.Picking;
			List<UITask> list = new List<UITask>();
			list.Add(new UITask(new UITaskDlg(this.turnOnLight), 0u));
			list.Add(new UITask(new UITaskDlg(this.lockBgClick), 0u));
			list.Add(new UITask(new UITaskDlg(this.doPickBottle), 0u));
			list.Add(new UITask(new UITaskDlg(this.startMakeWaterAnimation), 0u));
			List<UITask> listTasks = list;
			UITaskManager uITaskManager = new UITaskManager(listTasks, null);
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.turnOffLight));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.stopMakeWaterAnimation));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.stopFloatObjectAnimation));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.refreshUnReadBottle));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.pickBottleFinished));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.unLockBgClick));
			uITaskManager.StartTasks(0u);
		}
		private void pickBottleFinished()
		{
			this.mBIsPicking = false;
			this.mPickingStatus = DriftBottleMainPage.PickingStatus.NotPicking;
			this.stopShowPickTask();
			this.stopOpenBtlTask();
		}
		private void setBackGround()
		{
			int hour = DateTime.get_Now().get_Hour();
			if (hour >= 6 && hour < 18)
			{
				this.changeToDayMode();
				return;
			}
			this.changeToNightMode();
		}
		private void changeToDayMode()
		{
			this.mDayOrNight = DriftBottleMainPage.DayOrNight.Day;
			this.startBaloonAnimation();
			this.stopTowerLightAnimation();
			this.imgMoon.set_Visibility(1);
			this.imgBrushBG.set_ImageSource(new BitmapImage(new Uri("/Source/Plugin/DriftBottle/Resource/Img/day_bg.jpg", 0)));
		}
		private void changeToNightMode()
		{
			this.mDayOrNight = DriftBottleMainPage.DayOrNight.Night;
			this.stopBaloonAnimation();
			this.startTowerLightAnimation();
			this.imgMoon.set_Visibility(0);
			this.imgBrushBG.set_ImageSource(new BitmapImage(new Uri("/Source/Plugin/DriftBottle/Resource/Img/night_bg.jpg", 0)));
			this.imgMoon.set_Source(new BitmapImage(new Uri(this.getMoonSource(), 0)));
		}
		private string getMoonSource()
		{
			DateTime now = DateTime.get_Now();
			int num = 15;
			int num2 = 7;
			try
			{
				num = LunarDay.GetLunarCalendarDay(now);
			}
			catch (Exception)
			{
			}
			int num3 = num2 * num / 30 + 1;
			num3 = num2 + 1 - num3;
			if (num3 <= 0)
			{
				num3 = 1;
			}
			if (num3 > 7)
			{
				num3 = 7;
			}
			return "/Source/Plugin/DriftBottle/Resource/Img/sandyMoon00" + num3 + ".png";
		}
		private void initUI()
		{
			if (this.mBIsUIInited)
			{
				return;
			}
			this.mBIsUIInited = true;
			this.setBackGround();
		}
		private void toWriteMsgMode()
		{
			if (!DriftBottleServiceCenter.isThrowBottleCountLeft())
			{
				MMMessageBox.Show(strings.Float_Bottle_No_Throw_Bottle, true, "确定");
				return;
			}
			WriteDriftBottleMsgCtrl uielement = new WriteDriftBottleMsgCtrl(new WriteDriftBottleMsgCtrl.SendMsgHandler(this.sendMsgHandler));
			this.putElementAbove(uielement);
			this.turnOnBlackCover();
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.outWriteMsgMode));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.turnOffBlackCover));
			DriftBottleMainPage.lockUndo();
		}
		private void outWriteMsgMode()
		{
			this.removeElementAbove();
		}
		private void startSendVoice()
		{
			ThrowVoiceBottleService.startDoSence();
		}
		private void sendMsgHandler(MsgBottleKind sendMsgKind, WriteBtlOpKind opkind = WriteBtlOpKind.OpKind_Null)
		{
			if (opkind == WriteBtlOpKind.OpKind_WritingVoice)
			{
				if (this.mDayOrNight == DriftBottleMainPage.DayOrNight.Day)
				{
					this.stopBaloonAnimation();
					this.imgBalloon.set_Visibility(0);
				}
				return;
			}
			if (opkind == WriteBtlOpKind.OpKind_FinishVoice)
			{
				if (this.mDayOrNight == DriftBottleMainPage.DayOrNight.Day)
				{
					this.startBaloonAnimation();
				}
				return;
			}
			uint tDuaration = 0u;
			Log.smethod_5("DriftBottleMainPage", "sendMsgHandler:msg kind = " + sendMsgKind);
			if (MsgBottleKind.Bt_Letter == sendMsgKind)
			{
				tDuaration = 500u;
			}
			else
			{
				if (MsgBottleKind.Bt_Voice == sendMsgKind)
				{
					tDuaration = 0u;
					this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.startSendVoice));
				}
				else
				{
					if (sendMsgKind == MsgBottleKind.Bt_Null)
					{
						DriftBottleMainPage.unlockUndo();
						this.doUndo();
						return;
					}
				}
			}
			List<UITask> list = new List<UITask>();
			list.Add(new UITask(new UITaskDlg(DriftBottleMainPage.lockUndo), tDuaration));
			list.Add(new UITask(new UITaskDlg(this.turnOnLight), 0u));
			list.Add(new UITask(new UITaskDlgEx(this.setMsgBottleKind), MsgBottleKind.Bt_Null, 0u));
			list.Add(new UITask(new UITaskDlg(this.showMsgBottle), WriteDriftBottleMsgCtrl.cNLoadMsgDuaration - 200u));
			list.Add(new UITask(new UITaskDlg(this.hideMsgObject), 0u));
			list.Add(new UITask(new UITaskDlgEx(this.setMsgBottleKind), sendMsgKind, 0u));
			list.Add(new UITask(new UITaskDlg(this.startShowMsgObjectAni), 200u));
			list.Add(new UITask(new UITaskDlg(this.removeElementAbove), 800u));
			list.Add(new UITask(new UITaskDlg(this.throwBottleAnimation), 3200u));
			list.Add(new UITask(new UITaskDlg(this.turnOffLight), 0u));
			list.Add(new UITask(new UITaskDlg(DriftBottleMainPage.unlockUndo), 0u));
			list.Add(new UITask(new UITaskDlg(this.doUndo), 0u));
			list.Add(new UITask(new UITaskDlg(this.doClean), 0u));
			List<UITask> listTasks = list;
			UITaskManager uITaskManager = new UITaskManager(listTasks, null);
			uITaskManager.StartTasks(0u);
		}
		private void putElementAbove(UIElement uielement)
		{
			if (uielement != null)
			{
				this.removeElementAbove();
			}
			this.mElementAbove = uielement;
			this.LayoutRoot.get_Children().Add(this.mElementAbove);
		}
		private void removeElementAbove()
		{
			if (this.mElementAbove != null)
			{
				this.LayoutRoot.get_Children().Remove(this.mElementAbove);
				this.mElementAbove = null;
			}
		}
		private void setMsgBottleEmpty()
		{
			this.imgMsgObject.set_Source(null);
		}
		private void setMsgBottleKind(object object_0)
		{
			if (object_0 != null && object_0 is MsgBottleKind)
			{
				MsgBottleKind msgBottleKind = (MsgBottleKind)object_0;
				string text = "";
				if (msgBottleKind == MsgBottleKind.Bt_Null)
				{
					text = "/Source/Plugin/DriftBottle/Resource/Img/bottleEmpty.png";
				}
				else
				{
					if (MsgBottleKind.Bt_Voice == msgBottleKind)
					{
						text = "/Source/Plugin/DriftBottle/Resource/Img/bottleVoice.png";
					}
					else
					{
						if (MsgBottleKind.Bt_Letter == msgBottleKind)
						{
							text = "/Source/Plugin/DriftBottle/Resource/Img/bottleLetter.png";
						}
					}
				}
				this.imgMsgObject.set_Source(new BitmapImage(new Uri(text, 0)));
				return;
			}
		}
		private void setMsgBottleLetter()
		{
		}
		private void setMsgBottleVoice()
		{
		}
		private void showMsgBottle()
		{
			this.mElementToThrow.set_Visibility(0);
		}
		private void hideMsgObject()
		{
			this.imgMsgObject.set_Opacity(0.0);
		}
		private void hideMsgBottle()
		{
			this.mElementToThrow.set_Visibility(1);
		}
		private object getBtleMsg()
		{
			return this.mBtleMsg;
		}
		private void deleteBtle()
		{
			if (this.mBtleMsg != null)
			{
				BConversationMgr.delBottle(this.mBtleMsg.strTalker);
				this.clearBtleMsg();
			}
		}
		private object throwBack()
		{
			this.setMsgBottleKind(MsgBottleKind.Bt_Letter);
			List<UITask> list = new List<UITask>();
			list.Add(new UITask(new UITaskDlg(DriftBottleMainPage.lockUndo), 0u));
			list.Add(new UITask(new UITaskDlg(this.turnOnLight), 0u));
			list.Add(new UITask(new UITaskDlgEx(this.setMsgBottleKind), this.mLastPickedBtleKind, 0u));
			list.Add(new UITask(new UITaskDlg(this.showMsgBottle), 0u));
			list.Add(new UITask(new UITaskDlg(this.removeElementAbove), 300u));
			list.Add(new UITask(new UITaskDlg(this.throwBottleAnimation), 3200u));
			list.Add(new UITask(new UITaskDlg(this.stopMakeWaterAnimation), 0u));
			list.Add(new UITask(new UITaskDlg(this.turnOffLight), 0u));
			list.Add(new UITask(new UITaskDlg(this.deleteBtle), 0u));
			list.Add(new UITask(new UITaskDlg(DriftBottleMainPage.unlockUndo), 0u));
			list.Add(new UITask(new UITaskDlg(this.doUndo), 0u));
			list.Add(new UITask(new UITaskDlg(this.outOpenBtleMode), 0u));
			List<UITask> listTasks = list;
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.turnOffLight));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.hideMsgBottle));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.stopMakeWaterAnimation));
			UITaskManager uITaskManager = new UITaskManager(listTasks, null);
			uITaskManager.StartTasks(0u);
			return null;
		}
		private object replyMsgBottle()
		{
			string text = null;
			if (this.mBtleMsg != null)
			{
				text = this.mBtleMsg.strTalker;
			}
			this.outOpenBtleMode();
			if (text != null)
			{
				ChatContainerPage.GoToChatPage(this, text, null, null, null);
			}
			return null;
		}
		private void toOpenBtleMode()
		{
			DriftBottleMainPage.unlockUndo();
			this.putOneThingToIgnoreList(new DriftBottleMainPage.UnDoDlg(this.turnOffLight));
			this.doUndo();
			this.lockBgClick();
			this.remFromIgnoreUndoList(new DriftBottleMainPage.UnDoDlg(this.turnOffLight));
			ShowBottleMsgCtrl uielement = new ShowBottleMsgCtrl(new UITaskDlgExHasRet(this.showBtleHandler));
			this.putElementAbove(uielement);
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.outOpenBtleMode));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.turnOffLight));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.turnOffBlackCover));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.removeElementAbove));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.refreshUnReadBottle));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.clearBtleMsg));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.unLockBgClick));
		}
		private object showBtleHandler(object object_0)
		{
			if (object_0 == null)
			{
				return null;
			}
			ShowBtleRet showBtleRet = (ShowBtleRet)object_0;
			Log.smethod_5("DriftBottleMainPage", "showBtleHandler:op kind = " + showBtleRet);
			switch (showBtleRet)
			{
			case ShowBtleRet.RetKind_JustBack:
				this.outOpenBtleMode();
				break;
			case ShowBtleRet.RetKind_Reply:
				return this.replyMsgBottle();
			case ShowBtleRet.RetKind_Throw:
				return this.throwBack();
			case ShowBtleRet.RetKind_GetBtle:
				return this.getBtleMsg();
			case ShowBtleRet.RetKind_CtrlLoaded:
				this.turnOffLight();
				this.turnOnBlackCover();
				this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.turnOffBlackCover));
				return null;
			case ShowBtleRet.RetKind_BackKeyDisable:
				this.disableBackKeyHandler();
				return null;
			case ShowBtleRet.RetKind_BackKeyEnable:
				this.enableBackKeyHandler();
				return null;
			}
			return null;
		}
		private void outOpenBtleMode()
		{
			DriftBottleMainPage.unlockUndo();
			this.doUndo();
		}
		private bool canClickBg()
		{
			return !this.mBIsLockBgClick;
		}
		private void lockBgClick()
		{
			this.mBIsLockBgClick = true;
		}
		private void unLockBgClick()
		{
			this.mBIsLockBgClick = false;
		}
		private void refreshUnReadBottle()
		{
			int unReadCountAll = BConversationMgr.getUnReadCountAll();
			if (unReadCountAll > 0)
			{
				this.gridBtleCnt.set_Visibility(0);
				this.txtBtleCnt.set_Text(string.Concat(unReadCountAll));
				return;
			}
			this.gridBtleCnt.set_Visibility(1);
		}
		private void showFloatObject()
		{
			this.imgFloatObject.set_Visibility(0);
		}
		private void hideFloatObject()
		{
			this.imgFloatObject.set_Visibility(1);
		}
		private ApplicationBar setAppBar()
		{
			if (this.mBar != null)
			{
				if (!this.mBar.get_IsVisible())
				{
					this.mBar.set_IsVisible(true);
				}
				return this.mBar;
			}
			this.mBar = new ApplicationBar();
			this.mBar.set_IsMenuEnabled(true);
			this.mBar.set_IsVisible(true);
			ApplicationBarMenuItem applicationBarMenuItem = new ApplicationBarMenuItem(strings.COM_Setting);
			applicationBarMenuItem.add_Click(new EventHandler(this.btnSetting_Click));
			this.mBar.get_MenuItems().Add(applicationBarMenuItem);
			base.set_ApplicationBar(this.mBar);
			this.setAppBarStyle(base.get_ApplicationBar());
			return this.mBar;
		}
		private void btnSetting_Click(object sender, EventArgs e)
		{
			base.GoToPage("/Source/Plugin/DriftBottle/UI/DriftBottleSettingPage.xaml", new object[]
			{
				PluginManager.findPluginByName("DriftBottle")
			}, false);
		}
		private void btnChangeDay_Click(object sender, EventArgs e)
		{
			if (this.mBIsDay)
			{
				this.changeToNightMode();
			}
			else
			{
				this.changeToDayMode();
			}
			this.mBIsDay = !this.mBIsDay;
		}
		private void btnPick_Click(object sender, EventArgs e)
		{
			this.changeToPickBottle();
		}
		private void btnLunar_Click(object sender, EventArgs e)
		{
			DateTime now = DateTime.get_Now();
			now = new DateTime(2015, 10, 1);
			LunarDay.GetLunarCalendarDay(now);
			now = new DateTime(2012, 4, 1);
			LunarDay.GetLunarCalendarDay(now);
			now = new DateTime(2012, 5, 1);
			LunarDay.GetLunarCalendarDay(now);
			now = new DateTime(2012, 6, 24);
			LunarDay.GetLunarCalendarDay(now);
		}
		private void btnThrow_Click(object sender, EventArgs e)
		{
			this.throwBottleAnimation();
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.stopMakeWaterAnimation));
			this.putOneThingToUndo(new DriftBottleMainPage.UnDoDlg(this.turnOffLight));
		}
		private void disableBackKeyHandler()
		{
			this.mBIsBackKeyEnabled = false;
		}
		private void enableBackKeyHandler()
		{
			this.mBIsBackKeyEnabled = true;
		}
		protected override void OnBackKeyPress(CancelEventArgs cancelEventArgs_0)
		{
			if (base.PreOnBackKeyPress(cancelEventArgs_0))
			{
				return;
			}
			if (!this.mBIsBackKeyEnabled)
			{
				return;
			}
			if (this.unDoOneThing())
			{
				cancelEventArgs_0.set_Cancel(true);
			}
			base.OnBackKeyPress(cancelEventArgs_0);
		}
		public static void lockUndo()
		{
			DriftBottleMainPage.sBIsUndoLocked = true;
		}
		public static void unlockUndo()
		{
			DriftBottleMainPage.sBIsUndoLocked = false;
		}
		public static bool canDoUndo()
		{
			return !DriftBottleMainPage.sBIsUndoLocked;
		}
		private bool unDoOneThing()
		{
			this.mNdoUnDoLevel++;
			if (!DriftBottleMainPage.canDoUndo())
			{
				this.mNdoUnDoLevel--;
				return true;
			}
			if (this.listUndos != null && this.listUndos.get_Count() != 0)
			{
				using (List<DriftBottleMainPage.UnDoDlg>.Enumerator enumerator = this.listUndos.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						DriftBottleMainPage.UnDoDlg current = enumerator.get_Current();
						if (current != null && !(current == new DriftBottleMainPage.UnDoDlg(this.doUndo)) && !this.isThingIgnored(current))
						{
							current();
						}
					}
				}
				this.mNdoUnDoLevel--;
				this.listUndos.Clear();
				return true;
			}
			this.mNdoUnDoLevel--;
			return false;
		}
		private void doUndo()
		{
			if (this.mNdoUnDoLevel > 0)
			{
				return;
			}
			this.mNdoUnDoLevel++;
			if (!DriftBottleMainPage.canDoUndo())
			{
				this.mNdoUnDoLevel--;
				return;
			}
			if (this.listUndos != null && this.listUndos.get_Count() != 0)
			{
				using (List<DriftBottleMainPage.UnDoDlg>.Enumerator enumerator = this.listUndos.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						DriftBottleMainPage.UnDoDlg current = enumerator.get_Current();
						if (current != null && !(current == new DriftBottleMainPage.UnDoDlg(this.doUndo)) && !this.isThingIgnored(current))
						{
							current();
						}
					}
				}
				this.listUndos.Clear();
				this.mNdoUnDoLevel--;
				return;
			}
			this.mNdoUnDoLevel--;
		}
		private void putOneThingToUndo(DriftBottleMainPage.UnDoDlg tUndoDlg)
		{
			if (this.listUndos != null)
			{
				this.listUndos.Add(tUndoDlg);
			}
		}
		private void putOneThingToIgnoreList(object ignoreThing)
		{
			if (this.mUndoIgnore == null)
			{
				this.mUndoIgnore = new List<DriftBottleMainPage.UnDoDlg>();
			}
			if (ignoreThing != null && ignoreThing is DriftBottleMainPage.UnDoDlg)
			{
				this.mUndoIgnore.Add((DriftBottleMainPage.UnDoDlg)ignoreThing);
			}
		}
		private void remFromIgnoreUndoList(object ignoreThing)
		{
			if (this.mUndoIgnore == null)
			{
				return;
			}
			if (ignoreThing != null && ignoreThing is DriftBottleMainPage.UnDoDlg)
			{
				this.mUndoIgnore.Remove((DriftBottleMainPage.UnDoDlg)ignoreThing);
			}
		}
		private void clearIgnoreUndoList()
		{
		}
		private bool isThingIgnored(DriftBottleMainPage.UnDoDlg unDoDlg_0)
		{
			return unDoDlg_0 != null && (this.mUndoIgnore != null && this.mUndoIgnore.Contains(unDoDlg_0));
		}
		private void doClean()
		{
			DriftBottleServiceCenter.checkCleanThrowBottle();
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/DriftBottle/UI/DriftBottleMainPage.xaml", 2));
			this.realLayoutRoot = (Grid)base.FindName("realLayoutRoot");
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.imgBrushBG = (ImageBrush)base.FindName("imgBrushBG");
			this.imgBalloon = (Image)base.FindName("imgBalloon");
			this.imgMoon = (Image)base.FindName("imgMoon");
			this.imgTowerLight = (Image)base.FindName("imgTowerLight");
			this.canvasRoot = (Canvas)base.FindName("canvasRoot");
			this.btnRoot = (Button)base.FindName("btnRoot");
			this.canvasToolBar = (Grid)base.FindName("canvasToolBar");
			this.btnThrowBottle = (Button)base.FindName("btnThrowBottle");
			this.btnPickBottle = (Button)base.FindName("btnPickBottle");
			this.btnSeeMyBottles = (Button)base.FindName("btnSeeMyBottles");
			this.gridBtleCnt = (Grid)base.FindName("gridBtleCnt");
			this.txtBtleCnt = (TextBlock)base.FindName("txtBtleCnt");
			this.canvasMsgBottle = (Canvas)base.FindName("canvasMsgBottle");
			this.imgMsgBottle = (Image)base.FindName("imgMsgBottle");
			this.imgMsgObject = (Image)base.FindName("imgMsgObject");
			this.btnFloatObject = (Button)base.FindName("btnFloatObject");
			this.imgFloatObject = (Image)base.FindName("imgFloatObject");
			this.canvasWaterFlower = (Canvas)base.FindName("canvasWaterFlower");
			this.imgWaterFlower1 = (Image)base.FindName("imgWaterFlower1");
			this.imgWaterFlower2 = (Image)base.FindName("imgWaterFlower2");
			this.imgWaterFlower3 = (Image)base.FindName("imgWaterFlower3");
			this.panelOpenHint = (StackPanel)base.FindName("panelOpenHint");
			this.imgOpenHint = (Image)base.FindName("imgOpenHint");
			this.txtOpenHint = (TextBlock)base.FindName("txtOpenHint");
		}
	}
}
